﻿using System;
using PostSharp.Aspects;
using BizElements.BusinessLayer;

namespace BizElements.BusinessLayer.Aspects
{
    /// <summary>
    /// Generates global and user cache keys used by <see cref="CachedAttribute"/>.
    /// </summary>
    public interface ICacheKeyGenerator
    {
        #region Methods.

        /// <summary>
        /// Tries to get user for which the data is cached.
        /// </summary>
        /// <param name="postsharpEventArgs">Event arguments specifying which method is being executed and which are its arguments.</param>
        /// <returns><b>IActor</b> object or <b>null</b> if user cannot be determined.</returns>
        IActor GetActor(MethodExecutionArgs postsharpEventArgs);

        /// <summary>
        /// Generates cache key for the method's return value.
        /// </summary>
        /// <param name="eventArgs">Event arguments specifying which method is being executed and which are its arguments.</param>
        /// <param name="includeActorObject">Whether to include actor in the cache key.</param>
        /// <param name="mutableParamsAllowed">Whether cache key can be generated for mutable objects.</param>
        /// <returns>A string which represents a unique cache key or <b>null</b> if key cannot be generated.</returns>
        string GetCacheKey(MethodExecutionArgs eventArgs, bool includeActorObject, bool mutableParamsAllowed);

        #endregion
    }
}